package com.zhixi.pattern.notimportant.visitorpattern;

import com.zhixi.pattern.notimportant.visitorpattern.operation.*;

import java.util.ArrayList;
import java.util.List;

/**
 * 访问者模式
 *
 * @作者 ShuHaoNan
 * @邮箱 shuhaonan1@gmail.com
 * @时间 2020/11/20 10:17
 */
public class VisitorPattern {

    public static void main(String[] args) {
        List<Employee> employees = mockEmployee();
        employees.forEach(employee -> {
            employee.accept(new Visitor());
        });
    }

    /**
     * 模拟数据库数据
     */
    private static List<Employee> mockEmployee() {
        ArrayList<Employee> employees = new ArrayList<>();
        Manager manager = new Manager();
        manager.setName("zs");
        manager.setSalary(30000);
        employees.add(manager);
        CommonEmployee commonEmployee = new CommonEmployee();
        commonEmployee.setName("ls");
        commonEmployee.setSalary(4000);
        employees.add(commonEmployee);
        CommonEmployee commonEmployee1 = new CommonEmployee();
        commonEmployee1.setName("ww");
        commonEmployee1.setSalary(5000);
        employees.add(commonEmployee1);
        return employees;
    }

}
